/* {{ FNameTag }} FSM(Finite State Machine，有限状态机) Header File  */
#ifndef _{{ FNameTag | upper }}_FSM_H_
#define _{{ FNameTag | upper }}_FSM_H_


#ifdef __cplusplus
extern "C"
{
#endif

enum T{{ Target }}FsmStateTag
{
{%- for state in StateDef %}
    k{{ Target }}FsmState{{ state.name }} = {{ state.eid }},    ///< {{ state.brief }}
{%- endfor %}
    T{{ Target }}FsmStateMax
};
typedef enum T{{ Target }}FsmStateTag T{{ Target }}FsmState;


typedef struct T{{ Target }}FsmTag T{{ Target }}Fsm;
struct T{{ Target }}FsmTag
{
    void *user_param;               
    T{{ Target }}FsmState curr_state;
    T{{ Target }}FsmState next_state;
    T{{ Target }}FsmState prev_state;

{%- for var in StateVar %}
    {{ var.varType }} {{ var.name }};  ///< {{ var.varBrief }}
{%- endfor %}
};

void T{{ Target }}FsmCreate(T{{ Target }}Fsm *self, void *user_param);
void T{{ Target }}FsmDestroy(T{{ Target }}Fsm *self);

void T{{ Target }}FsmInit(T{{ Target }}Fsm *self);
void T{{ Target }}FsmDone(T{{ Target }}Fsm *self);

void T{{ Target }}FsmRunOnce(T{{ Target }}Fsm *self);


const char *{{ Target }}FsmStateName(T{{ Target }}FsmState state);

#ifdef __cplusplus
}  ///< extern "C"
#endif

#endif  ///< _{{ Target | upper }}_FSM_H_




